package com.jadows.tdog.controller;

import com.jadows.tdog.base.R;
import com.jadows.tdog.domain.ChatRoom;
import com.jadows.tdog.service.ChatRoomService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

/**
 * @author taojiacheng
 */
@RestController
@RequestMapping("/room")
@RequiredArgsConstructor
public class ChatRoomController {

    final ChatRoomService chatRoomService;

    /**
     * 发起群聊
     */
    @PostMapping("/create")
    public R<ChatRoom> createRoom(@RequestBody Set<String> targetUserIds) {
        ChatRoom chatRoom = chatRoomService.createRoom(targetUserIds);
        return R.ok(chatRoom);
    }

    /**
     * 获取当前用户已经加入的群聊
     */
    @GetMapping("/list")
    public R<Set<ChatRoom>> listRooms() {
        Set<ChatRoom> chatRooms = chatRoomService.listRooms();
        return R.ok(chatRooms);
    }


}
